//
//  UILabel+Extension.swift
//  SinaWeibo
//
//  Created by Tony-ztb on 15/12/18.
//  Copyright © 2015年 Tony-ztb. All rights reserved.
//

import UIKit


extension UILabel {
    
    // 便利的构造函数  基于本类的构造函数扩展
    convenience init(title: String, color: UIColor, fontSize: CGFloat, margin: CGFloat = 0) {
        self.init()
        text = title
        textColor = color
        textAlignment = .Center
        font = UIFont.systemFontOfSize(fontSize)
        numberOfLines = 0
        if margin > 0 {
            // 最大宽度
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * margin
            
            textAlignment = .Left
        }
        
        sizeToFit()

    }
}